# Your RandomizedSet object will be instantiated and called as such:
# obj = RandomizedSet()
# param_1 = obj.insert(val)
# param_2 = obj.remove(val)
# param_3 = obj.getRandom()
import random


class RandomizedSet:
    def __init__(self):
        self.m_set = dict()
        self.m_list = list()

    def insert(self, val: int) -> bool:
        if val not in self.m_set:
            self.m_set[val] = len(self.m_list)
            self.m_list.append(val)
            return True
        return False

    def remove(self, val: int) -> bool:
        if val in self.m_set:
            index = self.m_set.pop(val)
            if self.m_set:
                try:
                    self.m_list[index] = self.m_list.pop(-1)
                    self.m_set[self.m_list[index]] = index
                except:
                    pass
            else:
                self.m_list = list()
            return True
        return False

    def getRandom(self) -> int:
        return self.m_list[random.randint(0, len(self.m_list)-1)]


a = RandomizedSet()
print(a.insert(3))
print(a.insert(3))
print(a.getRandom())
print(a.getRandom())
print(a.insert(1))
print(a.remove(3))
print(a.getRandom())
print(a.getRandom())
print(a.insert(0))
print(a.remove(0))
